package team.xstudio.bedwarstoolkit.misc

import net.minecraft.commands.Commands.literal
import net.minecraftforge.event.RegisterCommandsEvent
import team.xstudio.bedwarstoolkit.ingame.BWGameManager
import team.xstudio.bedwarstoolkit.utils.BWUtils

/**
 * Created in 2025/6/10
 * Project: bedwarstoolkit
 *
 * @author <a href="https://github.com/Bread-Nicecat">Bread_NiceCat</a>
 * <p>
 *
 * <p>
 **/
object BWCommands {
    fun onRegisterCommands(event: RegisterCommandsEvent) {
        BWUtils.LOGGER.info("onRegisterCommands")
        val dispatcher = event.dispatcher
        val game = literal("game")
            .then(literal("list").executes {
                val games = BWGameManager.getGames().toList()
                return@executes games.count()
            })
            .then(literal("_create").executes {
                BWGameManager.newGame()
                1
            })
            .then(literal("_end"))


        dispatcher.register(literal("bedwarstoolkit").then(game))
        dispatcher.register(literal("bwt").then(game))
    }

}